package dao

import (
	Mysql "selfService/Databases"
	"selfService/兴趣相关/models"

)
// 兴趣收集表
type Interest_colloct_dao struct {
}

// 查询并返回所有数据
func (tiss *Interest_colloct_dao)GetAll() *[]models.Interest_collect  {
	result := &[]models.Interest_collect{}
	Mysql.DB.Find(result)
	return result
}

// 传入id 查询该id对应的兴趣
func (this *Interest_colloct_dao)GetInterestById(id string) *models.Interest_collect  {
	result := &models.Interest_collect{}
	Mysql.DB.Where("id = ?", id).First(result)
	return result
}

// 添加兴趣
func (this *Interest_colloct_dao)Insert(interestCollect *models.Interest_collect)string  {
		//mod := &models.Interest_collect{};
		//mod.Revision = interestCollect.Revision
		//mod.Created_by = interestCollect.CreatedBy
		//mod.Updated_time = interestCollect.UpdatedTime
		//mod.Id = interestCollect.Id
		//mod.Keep_field1 = interestCollect.KeepField1
		//mod.Keep_field2 = interestCollect.KeepField2
		//mod.Interest_name = interestCollect.InterestName
		// db.Create(&animal)
		Mysql.DB.Create(interestCollect)
	return "成功"
}

//根据id  删除兴趣选项
func (*Interest_colloct_dao) DeleteInterest(id string)bool {
	result := &models.Interest_collect{}
	Mysql.DB.Where("id = ?",id).Delete(result)
	return true
}

//根据id  修改兴趣选项
func (*Interest_colloct_dao)UpdateInterest(id string,interest_name string)string  {
	// db.Model(&user).Where("active = ?", true).Update("name", "hello")
	result := &models.Interest_collect{}
	Mysql.DB.Model(result).Where("id = ?",id).Update("interest_name",interest_name)
	return "成功"
}



